package cn.hfatec.shms.web.xh.xhHfjl.service;

import java.util.List;
import java.util.HashMap;


import cn.hfatec.shms.advice.annotation.MysqlDataSource;
import cn.hfatec.shms.advice.annotation.OracleDataSource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.hfatec.base.BaseDao;
import cn.hfatec.Page;
import cn.hfatec.Table;
import cn.hfatec.shms.web.xh.xhHfjl.model.XhHfjl;
import cn.hfatec.shms.web.xh.xhHfjl.dao.XhHfjlDao;
import cn.hfatec.shms.web.xh.xhHfjl.model.XhHfjlParams;

import javax.annotation.Resource;



/**
 *
 * @author hfatec
 * @version 1.0
 *
 * the JAVA code is generate by middlegen
 *
 */
@Service("XhHfjlService")
public class XhHfjlService {

    public static final String BEAN_ID = "XhHfjlService";

    //注入Dao层
    @Resource(name = "XhHfjlDao")
    private XhHfjlDao xhHfjlDao;

    //注入BaseDao
    @Resource(name = "BaseDao")
    private BaseDao baseDao;

    /**
     *
     * 查询数据
     *
     * @param xhHfjlParams
     * @param page
     *
     */
    @Transactional
    @MysqlDataSource
    public Table queryXhHfjlTable(XhHfjlParams xhHfjlParams, Page page){

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("params", xhHfjlParams);
        return baseDao.queryTableByPage("queryXhHfjl", params, page);
    }


    /**
     *
     * 根据ID获取数据
     * @param executeStart
     * @param executeEnd
     *
     */
    @Transactional
    @OracleDataSource
    public List<XhHfjl> getXhHfjlList(String executeStart, String executeEnd) {

        return xhHfjlDao.getXhHfjlByList(executeStart,executeEnd);
    }


    /**
     * 删除数据
     *
     * @param executeStart
     * @param executeEnd
     */
    @Transactional
    @MysqlDataSource
    public void deleteXhHfjls(String executeStart, String executeEnd) {

        xhHfjlDao.deletes(executeStart,executeEnd);
    }
    /**
     *
     * 插入数据
     * @param xhHfjl
     *
     */
    @Transactional
    @MysqlDataSource
    public void saveXhHfjl(XhHfjl xhHfjl) {
        if(xhHfjl.getId() != null) {
            XhHfjl result = getXhHfjl(xhHfjl.getId());
            if(result != null) {
                xhHfjlDao.update(xhHfjl);
            } else {
                xhHfjlDao.insert(xhHfjl);
            }
        } else {
            xhHfjlDao.insert(xhHfjl);
        }
    }

    /**
     *
     * 删除数据
     * @param id
     *
     */
    @Transactional
    @MysqlDataSource
    public void deleteXhHfjl(Integer id) {

        xhHfjlDao.delete(id);
    }

    /**
     *
     * 删除数据
     * @param xhHfjlList
     *
     */
    @Transactional
    @MysqlDataSource
    public void deleteXhHfjlBatch(List<String> xhHfjlList) {
        for(String id : xhHfjlList) {
            deleteXhHfjl(Integer.valueOf(id));
        }
    }

    /**
     *
     * 根据ID获取数据
     * @param id
     *
     */
    @Transactional
    @MysqlDataSource
    public XhHfjl getXhHfjl(Integer id) {

        return xhHfjlDao.getXhHfjlById(id);
    }
}